import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'

import './assets/main.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from "element-plus/lib/locale/lang/zh-cn";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import {formatDate, replyTime} from '@/utils/util.js'

import MyComponent from '@/components/LevelTag'
import Window from '@/views/im/window'
import ContextMenu from '@/components/ContextMenu/index.vue'
import Direction from '@/directive'

import GlobalMethod from '@/utils/globalMethod'
import WindowManager from '@/utils/window'

import piniaPluginPersist from 'pinia-plugin-persist'

import * as IconFonts from '@ant-design/icons-vue';

// import WebSocketService from '@/websocket/websocket';
import Socket from './plugins/websocket'

const app = createApp(App)
const store = createPinia()
store.use(piniaPluginPersist)
app.use(store)

app.use(Socket, {
  connection: 'ws://localhost:8080/chat',
})
app.component('context-menu', ContextMenu)

for (const [key, component] of Object.entries(IconFonts)) {
  app.component('ant' + key, component)
}

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(MyComponent)
app.use(Window).use(GlobalMethod).use(WindowManager)

app.use(Direction)

app.config.globalProperties.formatDate = formatDate
app.config.globalProperties.replyTime = replyTime


app.use(router)



app.use(ElementPlus, {locale})

app.mount('#app')
// app.use(WebSocketService)
